package com.softwaredesign.springboot.mapper;

import com.softwaredesign.springboot.entity.Authority;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface AuthorityMapper {

    @Select("select * from sys_authority limit #{pageNum}, #{pageSize}")
    List<Authority> findAll(Integer pageNum, Integer pageSize);

    @Select("select count(*) from sys_authority")
    Integer findAllTotal();

    @Select("select * from sys_authority " +
            "where (authorityName like #{authorityName}) " +
            "limit #{pageNum}, #{pageSize}")
    List<Authority> selectPage(Integer pageNum, Integer pageSize, String authorityName);

    @Select("select count(*) from sys_authority " +
            "where (authorityName like #{authorityName})")
    Integer selectTotal(String authorityName);

    @Update("update sys_authority " +
            "set authorityName = #{authorityName} " +
            "where id = #{id}")
    int update(Authority authority);
}
